// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
 * @file test_data.cpp
 * This source file contains the definition of the described types in the IDL file.
 *
 * This file was generated by the tool gen.
 */

#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace {
char dummy;
}  // namespace
#endif  // _WIN32

#include "test_data.h"
#include <fastcdr/Cdr.h>

#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;

#include <utility>


test::Header::Header()
{
    // m_type com.eprosima.idl.parser.typecode.EnumTypeCode@67d48005
    m_type = test::kImage;
    // m_name com.eprosima.idl.parser.typecode.StringTypeCode@1aa7ecca
    m_name ="";

}

test::Header::~Header()
{


}

test::Header::Header(
        const Header& x)
{
    m_type = x.m_type;
    m_name = x.m_name;
}

test::Header::Header(
        Header&& x)
{
    m_type = x.m_type;
    m_name = std::move(x.m_name);
}

test::Header& test::Header::operator =(
        const Header& x)
{

    m_type = x.m_type;
    m_name = x.m_name;

    return *this;
}

test::Header& test::Header::operator =(
        Header&& x)
{

    m_type = x.m_type;
    m_name = std::move(x.m_name);

    return *this;
}

bool test::Header::operator ==(
        const Header& x) const
{

    return (m_type == x.m_type && m_name == x.m_name);
}

bool test::Header::operator !=(
        const Header& x) const
{
    return !(*this == x);
}

size_t test::Header::getMaxCdrSerializedSize(
        size_t current_alignment)
{
    size_t initial_alignment = current_alignment;


    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);


    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1;


    return current_alignment - initial_alignment;
}

size_t test::Header::getCdrSerializedSize(
        const test::Header& data,
        size_t current_alignment)
{
    (void)data;
    size_t initial_alignment = current_alignment;


    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);


    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.name().size() + 1;


    return current_alignment - initial_alignment;
}

void test::Header::serialize(
        eprosima::fastcdr::Cdr& scdr) const
{

    scdr << (uint32_t)m_type;
    scdr << m_name.c_str();

}

void test::Header::deserialize(
        eprosima::fastcdr::Cdr& dcdr)
{

    {
        uint32_t enum_value = 0;
        dcdr >> enum_value;
        m_type = (test::Type)enum_value;
    }

    dcdr >> m_name;
}

/*!
 * @brief This function sets a value in member type
 * @param _type New value for member type
 */
void test::Header::type(
        test::Type _type)
{
    m_type = _type;
}

/*!
 * @brief This function returns the value of member type
 * @return Value of member type
 */
test::Type test::Header::type() const
{
    return m_type;
}

/*!
 * @brief This function returns a reference to member type
 * @return Reference to member type
 */
test::Type& test::Header::type()
{
    return m_type;
}

/*!
 * @brief This function copies the value in member name
 * @param _name New value to be copied in member name
 */
void test::Header::name(
        const std::string& _name)
{
    m_name = _name;
}

/*!
 * @brief This function moves the value in member name
 * @param _name New value to be moved in member name
 */
void test::Header::name(
        std::string&& _name)
{
    m_name = std::move(_name);
}

/*!
 * @brief This function returns a constant reference to member name
 * @return Constant reference to member name
 */
const std::string& test::Header::name() const
{
    return m_name;
}

/*!
 * @brief This function returns a reference to member name
 * @return Reference to member name
 */
std::string& test::Header::name()
{
    return m_name;
}

size_t test::Header::getKeyMaxCdrSerializedSize(
        size_t current_alignment)
{
    size_t current_align = current_alignment;





    return current_align;
}

bool test::Header::isKeyDefined()
{
    return false;
}

void test::Header::serializeKey(
        eprosima::fastcdr::Cdr& scdr) const
{
    (void) scdr;
      
}

test::Test::Test()
{
    // m_head com.eprosima.fastdds.idl.parser.typecode.StructTypeCode@689604d9

    // m_data com.eprosima.idl.parser.typecode.SequenceTypeCode@18078bef


}

test::Test::~Test()
{


}

test::Test::Test(
        const Test& x)
{
    m_head = x.m_head;
    m_data = x.m_data;
}

test::Test::Test(
        Test&& x)
{
    m_head = std::move(x.m_head);
    m_data = std::move(x.m_data);
}

test::Test& test::Test::operator =(
        const Test& x)
{

    m_head = x.m_head;
    m_data = x.m_data;

    return *this;
}

test::Test& test::Test::operator =(
        Test&& x)
{

    m_head = std::move(x.m_head);
    m_data = std::move(x.m_data);

    return *this;
}

bool test::Test::operator ==(
        const Test& x) const
{

    return (m_head == x.m_head && m_data == x.m_data);
}

bool test::Test::operator !=(
        const Test& x) const
{
    return !(*this == x);
}

size_t test::Test::getMaxCdrSerializedSize(
        size_t current_alignment)
{
    size_t initial_alignment = current_alignment;


    current_alignment += test::Header::getMaxCdrSerializedSize(current_alignment);
    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);

    current_alignment += (100 * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);




    return current_alignment - initial_alignment;
}

size_t test::Test::getCdrSerializedSize(
        const test::Test& data,
        size_t current_alignment)
{
    (void)data;
    size_t initial_alignment = current_alignment;


    current_alignment += test::Header::getCdrSerializedSize(data.head(), current_alignment);
    current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);

    if (data.data().size() > 0)
    {
        current_alignment += (data.data().size() * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
    }




    return current_alignment - initial_alignment;
}

void test::Test::serialize(
        eprosima::fastcdr::Cdr& scdr) const
{

    scdr << m_head;
    scdr << m_data;

}

void test::Test::deserialize(
        eprosima::fastcdr::Cdr& dcdr)
{

    dcdr >> m_head;
    dcdr >> m_data;
}

/*!
 * @brief This function copies the value in member head
 * @param _head New value to be copied in member head
 */
void test::Test::head(
        const test::Header& _head)
{
    m_head = _head;
}

/*!
 * @brief This function moves the value in member head
 * @param _head New value to be moved in member head
 */
void test::Test::head(
        test::Header&& _head)
{
    m_head = std::move(_head);
}

/*!
 * @brief This function returns a constant reference to member head
 * @return Constant reference to member head
 */
const test::Header& test::Test::head() const
{
    return m_head;
}

/*!
 * @brief This function returns a reference to member head
 * @return Reference to member head
 */
test::Header& test::Test::head()
{
    return m_head;
}
/*!
 * @brief This function copies the value in member data
 * @param _data New value to be copied in member data
 */
void test::Test::data(
        const std::vector<char>& _data)
{
    m_data = _data;
}

/*!
 * @brief This function moves the value in member data
 * @param _data New value to be moved in member data
 */
void test::Test::data(
        std::vector<char>&& _data)
{
    m_data = std::move(_data);
}

/*!
 * @brief This function returns a constant reference to member data
 * @return Constant reference to member data
 */
const std::vector<char>& test::Test::data() const
{
    return m_data;
}

/*!
 * @brief This function returns a reference to member data
 * @return Reference to member data
 */
std::vector<char>& test::Test::data()
{
    return m_data;
}

size_t test::Test::getKeyMaxCdrSerializedSize(
        size_t current_alignment)
{
    size_t current_align = current_alignment;





    return current_align;
}

bool test::Test::isKeyDefined()
{
    return false;
}

void test::Test::serializeKey(
        eprosima::fastcdr::Cdr& scdr) const
{
    (void) scdr;
      
}

